package com.benlai.newretail.jobhandler;

import com.benlai.newretail.entity.Menu;
import com.benlai.newretail.entity.PdaUser;
import com.benlai.newretail.entity.Role;
import com.benlai.newretail.service.IMenuService;
import com.benlai.newretail.service.IPdaUserService;
import com.benlai.newretail.service.IRoleService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHander;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author:gaoxu;
 * @Email:gaoxu@benlai.com
 * @DATE:2017-11-29
 * @version:ver1.0.0
 * @Description: Created by gaoxu on 2017-11-29.
 */

@JobHander(value = "helloJobHandler")
@Service
public class HelloJobHandler extends IJobHandler{

    @Autowired
    private IPdaUserService pdaUserService;

    @Autowired
    private IRoleService roleService;
    
    @Autowired
    private IMenuService menuService;

    @Override
    public ReturnT<String> execute(String... strings) throws Exception {
        XxlJobLogger.log(">>>>>>>>>>>>>>>>>>");
        PdaUser user = pdaUserService.getUserByNo("1001");
        XxlJobLogger.log(user.getUserName());
        XxlJobLogger.log(">>>>>>>>>>>>>>>>>>");
        Integer sysNo = 19;
        Menu menu = menuService.getMenuBySysNo(sysNo);
        XxlJobLogger.log(menu.getMenuName());
        XxlJobLogger.log(">>>>>>>>>>>>>>>>>>");
        Role role = roleService.getRoleById(new Integer(1));
        XxlJobLogger.log(role.getRoleName());
        return ReturnT.SUCCESS;
    }
}
